home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fsprefix / fsprefix.h < prev    next >
C/C++ Source or Header  |  1991-05-10  |  7KB  |  160 lines

  1. /*
  2.  * fsPrefix.h --
  3.  *
  4.  *    Definitions for the prefix table.  The prefix table is used to
  5.  *    map from a file name to a handle for the file's domain and the
  6.  *    relative name after the prefix.  The search key of the prefix table is,
  7.  *    of course, the prefix of the file name.  The relative name after the
  8.  *    prefix is also returned after searching the prefix table,  and the
  9.  *    server for a domain looks up this name relative to the root
  10.  *    of the domain.
  11.  *
  12.  * Copyright 1989 Regents of the University of California
  13.  * Permission to use, copy, modify, and distribute this
  14.  * software and its documentation for any purpose and without
  15.  * fee is hereby granted, provided that the above copyright
  16.  * notice appear in all copies.  The University of California
  17.  * makes no representations about the suitability of this
  18.  * software for any purpose.  It is provided "as is" without
  19.  * express or implied warranty.
  20.  *
  21.  * $Header: /sprite/src/kernel/fsprefix/RCS/fsprefix.h,v 9.3 91/05/10 12:42:09 mgbaker Exp $ SPRITE (Berkeley)
  22.  */
  23.  
  24. #ifndef _FSPREFIX
  25. #define _FSPREFIX
  26.  
  27. #include <list.h>
  28. #include <fs.h>
  29. #include <fsNameOps.h>
  30.  
  31. /*
  32.  * Fsprefix defines an entry in the prefix table.  Now it is just a linked
  33.  * list of items with the prefix as the key and the client's token as the
  34.  * data.  This structure requires an O(number of entries in the table)
  35.  * search each time a complete path name is opened.  A trie structure
  36.  * would be better because the time for the search would then be
  37.  * 0(length of valid prefix).
  38.  */
  39. typedef struct Fsprefix {
  40.     List_Links    links;        /* The prefix table is kept in a list */
  41.     char     *prefix;    /* The prefix is the key */
  42.     int        prefixLength;    /* It must match the file name this much */
  43.     Fs_HandleHeader *hdrPtr;    /* This data is the result of opening the
  44.                  * prefix (a directory) on the server */
  45.     int        domainType;    /* These are cached and used when trying to */
  46.     int        serverID;    /* re-establish a prefix table entry. */
  47.                 /* serverID is also used to find a prefix.
  48.                  * It contains the server id if it is
  49.                  * known, otherwise it contains the 
  50.                  * broadcast id. */
  51.     int        flags;        /* One of the flags defined below. */
  52.     /*
  53.      * At recovery time things are simpler if there are no active opens
  54.      * or closes.  The following counters, flags and condition variables
  55.      * are used to arrange this.
  56.      */
  57.     int        activeOpens;    /* Count of active opens in the domain */
  58.     Boolean    delayOpens;    /* TRUE if opens are delayed pending recovery */
  59.     Sync_Condition okToOpen;    /* Notified when opens can proceed */
  60.     Sync_Condition okToRecover;    /* Notified when there are no active opens */
  61.  
  62.     /*
  63.      * An export list can be kept for a prefix to control access.
  64.      * Support code is implemented but not tested, 9/87
  65.      */
  66.     List_Links    exportList;    /* List of remote hosts that this prefix
  67.                  * can be exported to.  If empty, all other
  68.                  * hosts have access. */
  69. } Fsprefix;
  70.  
  71. /*
  72.  * Type of prefix.
  73.  *
  74.  *    FSPREFIX_EXPORTED        This prefix is exported.
  75.  *    FSPREFIX_IMPORTED        This prefix is imported.
  76.  *    FSPREFIX_LOCAL            This prefix is local and private.
  77.  *    FSPREFIX_EXACT            As an argument to Fsprefix_Lookup, this
  78.  *                    constrains the lookup to succeed only
  79.  *                    on exact matches.
  80.  *    FSPREFIX_OVERRIDE        This flag, when passed to PrefixLoad,
  81.  *                    causes any existing flags to be
  82.  *                    sub-sumed by the passed-in flags.
  83.  *    FSPREFIX_LINK_NOT_PREFIX        This indicates that the caller really
  84.  *                    wants a handle on the link file, not
  85.  *                    the file referenced by the link.  This
  86.  *                    allows lstat() to get the remote link,
  87.  *                    regardless if there is a corresponding
  88.  *                    prefix installed.
  89.  *    FSPREFIX_LOCKED        The prefix cannot be deleted while
  90.  *                    this flag is set.  The iteration
  91.  *                    procedure uses this flag.
  92.  *    FSPREFIX_REMOTE        This is set when a prefix is loaded
  93.  *                    under a specific serverID.  This
  94.  *                    action ties the prefix to this server
  95.  *                    forever and causes prefix requests
  96.  *                    to be issued directly to the server
  97.  *                    instead of using broadcast.
  98.  *    FSPREFIX_ANY            This is passed to Fsprefix_HandleClose
  99.  *                    to indicate that any type of prefix
  100.  *                    is ok to nuke.  Fsprefix_HandleClose
  101.  *                    also takes FSPREFIX_LOCAL,
  102.  *                    FSPREFIX_EXPORTED, FSPREFIX_IMPORTED
  103.  *                    as types to remove.
  104.  *    FSPREFIX_FORCED        This prefix was forced to be loaded to avoid
  105.  *                    broadcasting for the server.
  106.  */
  107.  
  108. #define    FSPREFIX_EXPORTED        0x1
  109. #define    FSPREFIX_IMPORTED        0x2
  110. #define    FSPREFIX_LOCAL            0x4
  111. #define    FSPREFIX_EXACT            0x8
  112. #define    FSPREFIX_OVERRIDE        0x10
  113. #define FSPREFIX_LINK_NOT_PREFIX        0x20
  114. #define FSPREFIX_LOCKED        0x40
  115. #define FSPREFIX_REMOTE        0x80
  116. #define FSPREFIX_ANY            0x100
  117. #define FSPREFIX_FORCED            0x200
  118.  
  119.  
  120. extern Boolean fsprefix_FileNameTrace;
  121. /*
  122.  * Major prefix table entry points.
  123.  */
  124. extern void Fsprefix_Init _ARGS_((void));
  125. extern Fsprefix *Fsprefix_Install _ARGS_((char *prefix, 
  126.         Fs_HandleHeader *hdrPtr, int domainType, int flags));
  127. extern ReturnStatus Fsprefix_Lookup _ARGS_((char *fileName, int flags, 
  128.         int clientID, Fs_HandleHeader **hdrPtrPtr,
  129.         Fs_FileID *rootIDPtr, char **lookupNamePtr, int *serverIDPtr,
  130.         int *domainTypePtr, Fsprefix **prefixPtrPtr));
  131. extern void Fsprefix_Load _ARGS_((char *prefix, int serverID, int flags));
  132. /*
  133.  * Recovery related procedures
  134.  */
  135. extern void Fsprefix_Reopen _ARGS_((int serverID));
  136. extern void Fsprefix_AllowOpens _ARGS_((int serverID));
  137. extern void Fsprefix_RecoveryCheck _ARGS_((int serverID));
  138. extern ReturnStatus Fsprefix_OpenCheck _ARGS_((Fs_HandleHeader *prefixHdrPtr));
  139. extern int Fsprefix_OpenInProgress _ARGS_((Fs_FileID *fileIDPtr));
  140. extern void Fsprefix_OpenDone _ARGS_((Fs_HandleHeader *prefixHdrPtr));
  141. extern Fsprefix *Fsprefix_FromFileID _ARGS_((Fs_FileID *fileIDPtr));
  142. extern void Fsprefix_HandleClose _ARGS_((Fsprefix *prefixPtr, int flags));
  143.  
  144. extern ReturnStatus Fsprefix_LookupOperation _ARGS_((char *fileName, 
  145.         int operation, Boolean follow, Address argsPtr,
  146.         Address resultsPtr, Fs_NameInfo *nameInfoPtr));
  147. extern ReturnStatus FsprefixLookupRedirect _ARGS_((
  148.         Fs_RedirectInfo *redirectInfoPtr, Fsprefix *prefixPtr,
  149.         char **fileNamePtr));
  150. extern ReturnStatus Fsprefix_TwoNameOperation _ARGS_((int operation, 
  151.         char *srcName, char *dstName, Fs_LookupArgs *lookupArgsPtr));
  152.  
  153. extern Boolean Fsprefix_Clear _ARGS_((char *prefix, int deleteFlag, Boolean forced));
  154. extern ReturnStatus Fsprefix_DumpExport _ARGS_((int size, Address buffer));
  155. extern ReturnStatus Fsprefix_Dump _ARGS_((int index, Address argPtr));
  156. extern void Fsprefix_Export _ARGS_((char *prefix, int clientID,Boolean delete));
  157. extern Boolean Fsprefix_WasForced _ARGS_((char *prefix));
  158.  
  159. #endif _FSPREFIX
  160.